//
//  DSTagLabel.m
//  DemoTest
//
//  Created by DaShuEdu on 2017/5/10.
//  Copyright © 2017年 DaShuEdu. All rights reserved.
//

#import "DSTagLabel.h"

@implementation DSTagLabel

- (instancetype)initWithFrame:(CGRect)frame andInsets:(UIEdgeInsets)insets
{
    if (self = [super initWithFrame:frame]) {
        self.insets = insets;
    }
    return self;
}

- (instancetype)initWithInsets:(UIEdgeInsets)insets
{
    if (self = [super init]) {
        self.insets = insets;
    }
    return self;
}

- (void)drawTextInRect:(CGRect)rect
{
    return [super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.insets)];
}

- (CGFloat)lableWidthWith:(NSString *)labelString
{
    self.font = [UIFont systemFontOfSize:12];
    self.textColor = [UIColor blackColor];
    self.text = labelString;
    self.layer.borderColor = [UIColor blackColor].CGColor;
    self.layer.borderWidth = 1.f;
    CGSize size = [labelString sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]}];
    return (ceil(size.width)+10);
}

@end
